QuickOPC User's Guide and Reference
Create<TValue>(String,String,String,Int32) Method
Example 



OpcLabs.EasyOpcClassic Assembly > OpcLabs.EasyOpc.DataAccess.Reactive Namespace > DAItemChangedObservable Class > Create Method : Create<TValue>(String,String,String,Int32) Method
Name of the machine (empty string for local computer).
Contains ProgID of the OPC server.
ID of the item that will be subscribed to.
How often should the updates be received (number of milliseconds)
Creates a new item change observable for OPC item, specifying machine name, server class, item ID, requested update rate, and percent deadband.
Syntax
'Declaration
 
<NotNullAttribute()>
Public Overloads Shared Function Create(Of TValue)( _
   ByVal machineName As String, _
   ByVal serverClass As String, _
   ByVal itemId As String, _
   ByVal requestedUpdateRate As Integer _
) As DAItemChangedObservable(Of TValue)
'Usage
 
Dim machineName As String
Dim serverClass As String
Dim itemId As String
Dim requestedUpdateRate As Integer
Dim value As DAItemChangedObservable(Of TValue)
 
value = DAItemChangedObservable.Create(Of TValue)(machineName, serverClass, itemId, requestedUpdateRate)

Parameters

machineName
Name of the machine (empty string for local computer).
serverClass
Contains ProgID of the OPC server.
itemId
ID of the item that will be subscribed to.
requestedUpdateRate
How often should the updates be received (number of milliseconds)

Type Parameters

TValue

Return Value

Returns an observable for changes in the given OPC item.
Remarks
The DAReactive.DefaultClientSelector selector will be used for OPC Data Access operations.
Example

.NET

// Shows how to create an observable for OPC-DA item changes, and subscribe to it.

using System;
using System.Threading;
using OpcLabs.EasyOpc.DataAccess.Reactive;

namespace ReactiveDocExamples
{
    namespace _DAItemChangedObservable
    {
        partial class Subscribe
        {
            public static void Main1()
            {
                Console.WriteLine("Creating observable...");
                DAItemChangedObservable<double> ramp = 
                    DAItemChangedObservable.Create<double>("", "OPCLabs.KitServer.2", "Demo.Ramp", 1000);

                Console.WriteLine("Subscribing...");
                using (ramp.Subscribe(e => Console.WriteLine(
                    (e.Exception is null) ? e.Vtq.ToString() : e.Exception.GetBaseException().ToString())))
                {
                    Console.WriteLine("Waiting for 10 seconds...");
                    Thread.Sleep(10*1000);

                    Console.WriteLine("Unsubscribing...");
                }

                Console.WriteLine("Waiting for 2 seconds...");
                Thread.Sleep(2 * 1000);
            }
        }
    }
}
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also